import Vue from 'vue'
import Vuex from 'vuex'

import {
  bbsCollectQuery,
  bbsCollectDelete,
  bbsCollectAdd,
  bbsCollectUpdate,
  bbsCollectQueryById,
  bbsCollectCancel,
} from '@/api/bbs/bbsCollect'

Vue.use(Vuex)

const state = {}

const getters = {}

const actions = {
  //评论增删改查
  async queryBbsCollect({ commit }, listQuery) {
    let res = await bbsCollectQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async queryBbsCollectById({ commit }, id) {
    let res = await bbsCollectQueryById(id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async delBbsCollect({ commit }, row) {
    let res = await bbsCollectDelete(row.id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async addBbsCollect({ commit }, data) {
    let res = await bbsCollectAdd(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async cancelBbsCollect({ commit }, data) {
    let res = await bbsCollectCancel(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async updateBbsCollect({ commit }, data) {
    let res = await bbsCollectUpdate(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
}

const mutations = {}

export default {
  state,
  getters,
  actions,
  mutations,
}
